package validator;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class PersonValidator {
	public static final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMMM dd, yyyy", Locale.ENGLISH);
	
	private Integer id = null;
	private String firstName = null, lastName = null, identity = null;
	private Date birthday;
	
	
	public PersonValidator(String id,String firstName, String lastName, String identity, String birthday){
		try{
			this.id = Integer.parseInt(id);
		} catch(NullPointerException | NumberFormatException e){}
		if(firstName != null)this.firstName = !firstName.isEmpty() ? firstName : null;
		if(lastName != null)this.lastName = !lastName.isEmpty() ? lastName : null;
		if(identity != null)this.identity = !identity.isEmpty() ? identity : null;
		
		try {
			this.birthday = dateFormat.parse(birthday);
		} catch (NullPointerException | ParseException e) {			
			e.printStackTrace();
		}				
	}
	
	public boolean isValid(){
		return id != null && firstName != null && lastName != null && identity != null && birthday != null;		
	}
	
	public Integer getId() {
		return id;
	}


	public String getFirstName() {
		return firstName;
	}


	public String getLastName() {
		return lastName;
	}


	public String getIdentity() {
		return identity;
	}


	public Date getBirthday() {
		return birthday;
	}
	
	
}
